package com.lmscn.lms.api.model;

import com.jfinal.plugin.activerecord.Model;

import java.util.List;

/**
 * Created by Czl on 2015/10/23.
 */
@SuppressWarnings("serial")
public class CourseCategory extends Model<CourseCategory> {

    public static final CourseCategory dao = new CourseCategory();

    /**
     * @return
     */
    public List<CourseCategory> getCourseCategoryList(){
        return dao.find("select t.id, t.name, t.pid, t.seq from t_course_category t where t.pid =1 order by t.seq ");
    }

    /**
     * 获取二级分类
     * @return
     */
    public List<CourseCategory> getCourseCategorySecondList(Long pid){
        return dao.find("select t.id, t.name, t.pid, t.seq from t_course_category t"
        		+ " where t.pid = ? order by t.seq;", pid);
    }
    
	/**
	 * 根据ids模糊查询课程分类列表
	 * @param categoryId
	 * @return
	 */
	public List<CourseCategory> getByIdsLike(Long categoryId) {
		return dao.find("select t.id, t.name, t.pid, t.seq from t_course_category t where t.ids like '%,"+ categoryId +",%'");
	}
    
}
